﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Reflector.CodeDom
{
    public class CodeStackItem
    {
        public CodeStackItem(string activeBlock, string activeCollection, bool isCollection)
        {
            ActiveBlock = activeBlock;
            ActiveCollection = activeCollection;
            IsCollection = isCollection;
        }
        #region " Member Variables "
        private string activeBlock;
        private string activeCollection;
        private bool isCollection;
        #endregion
        #region " Properties "
        /// <summary>
        /// Gets or sets the active block.
        /// </summary>
        /// <value></value>
        public string ActiveBlock
        {
            get { return activeBlock; }
            set { activeBlock = value; }
        }
        /// <summary>
        /// Gets or sets the active collection.
        /// </summary>
        /// <value></value>
        public string ActiveCollection
        {
            get { return activeCollection; }
            set { activeCollection = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether this instance is collection.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is collection; otherwise, <c>false</c>.
        /// </value>
        public bool IsCollection
        {
            get { return isCollection; }
            set { isCollection = value; }
        }
        #endregion
        #region " Methods "
        /// <summary>
        /// Builds the code string.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public string BuildCodeString(string value)
        {
            string returnValue = "";
            if (isCollection)
            {
                returnValue = ActiveBlock + "." + ActiveCollection + ".Add("
                    + value + ");";
            }
            else
            {
                returnValue = activeBlock + "." + ActiveCollection + " = " + value + ";";
            }
            return returnValue;
        }
        #endregion
    }
}
